<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script>
                function title() {
                    document.getElementById('admin').className='selected';
                }
                window.onload=title;
            </script>

            <h:form id="incomeCreate" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Consultar 
                </h1>
                <p:messages showDetail="true" autoUpdate="true"  /> 
                <div class="row">
                    <div class="twelve columns">
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Filtros</h4></legend>
                            <p:panel id="resultPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix " >
                                <p:outputLabel value="Conta: " styleClass="grid_2" />
                                <p:autoComplete id="banco"  value="#{managerCash.contaBancaria}" 
                                                styleClass="grid_20" required="true"
                                                var="item1" forceSelection="true" dropdown="true" 
                                                minQueryLength="3" itemValue="#{item1}" itemLabel="#{item1}" 
                                                panelStyle="max-height:200px;"  
                                                completeMethod="#{managerCash.autocompleteContaBancarias}" 
                                                converter="contabancariaconverter">
                                </p:autoComplete>
                                <div class="clear"/>
                                <p:outputLabel value="De:" styleClass="grid_2"/>  
                                <div class="grid_5">
                                    <p:calendar value="#{managerCash.dateInitial}" 
                                                showOn="button" pattern="dd/MM/yyyy"/>
                                </div>
                                <p:outputLabel value="Até:" styleClass="grid_2"/>  
                                <div class="grid_5">
                                    <p:calendar value="#{managerCash.dateFinal}" 
                                                showOn="button" pattern="dd/MM/yyyy"/>
                                </div>

                                <div class="clear"/>

                                <div class="buttonAction">
                                    <p:commandButton value="Pesquisar" icon="ui-icon-search" process="@form"
                                                     update="@form"
                                                     actionListener="#{managerCash.pesquisar()}" />
                                </div>

                                <p:dataTable id="tableEntrada" var="in" value="#{managerCash.cashs}" 
                                             styleClass="grid_24"
                                             rowIndexVar="rowid"
                                             rowKey="#{in.id}"
                                             rows="15" paginator="true"  
                                             paginatorPosition="bottom"
                                             emptyMessage="Nenhum registro"
                                             >  
                                    <f:facet name="header">
                                        Registros
                                    </f:facet>
                                    <p:column headerText="Ações">  
                                       <p:button icon="ui-icon-search" style="position: relative;"  
                                                         alt="Visualizar" title="Visualizar"
                                                         outcome="createcash.xhtml">
                                            <f:param name="id" value="#{in.id}" />
                                        </p:button>
                                    </p:column>  
                                    <p:column headerText="Tipo" width="400">  
                                        <h:outputText value="#{in.typeIncome.name}"/>
                                    </p:column>  
                                    <p:column headerText="Data Realização" width="400">  
                                        <h:outputText value="#{in.creatAt}">
                                            <f:convertDateTime pattern="dd/MM/yyyy" />
                                        </h:outputText>
                                    </p:column>  
                                    <p:column headerText="Descrição"  style="white-space: pre-wrap;">  
                                        <h:outputText value="#{in.description}"/>
                                        <f:facet name="footer"> 
                                            <h:outputText value="Total" 
                                                          style="float: right; font-weight:bold;"/>
                                        </f:facet> 
                                    </p:column>  
                                    <p:column headerText="Valor Total" width="400" style="text-align: right;">  
                                        <h:outputText value="#{in.value}"/>
                                        <f:facet name="footer"> 
                                            <h:outputText value="#{managerCash.total}" 
                                                          style="float: right; font-weight:bold;"/>
                                        </f:facet> 
                                    </p:column>
                                </p:dataTable>

                            </p:panel>
                        </fieldset>
                    </div>
                </div>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
